package com.example.restatr.Atcivity.LivePayment;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import android.os.Bundle;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.restatr.Atcivity.Main.MainActivity;
import com.example.restatr.Bean.CardBean;
import com.example.restatr.R;
import com.example.restatr.Tools;
import com.google.android.material.tabs.TabLayout;
import com.youth.banner.Banner;

import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

public class LivePaymentAt extends AppCompatActivity {
    private Toolbar tb;
    private TextView barTitle;
    private EditText search;
    private Banner rbt;
    private GridView gridView;
    private TabLayout Tab;
    public static ViewPager XwPager;
    private List<CardBean> cardBeans=new ArrayList<>();
    private List<String> tabTitle=new ArrayList<>();
    public static List<String> tabId=new ArrayList<>();
    private List<Fragment> fragments=new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate( savedInstanceState );
        setContentView( R.layout.activity_shjf_at );

        tb = findViewById(R.id.toolbar);
        barTitle = findViewById(R.id.bar_Title);
        search = findViewById(R.id.search);
        rbt = findViewById(R.id.banner);
        gridView = findViewById(R.id.GridView);
        Tab = findViewById(R.id.Tab);
        XwPager = findViewById(R.id.XwPager);
        //设置卡片高度自适应
        LinearLayout.LayoutParams layoutParams =(LinearLayout.LayoutParams) gridView.getLayoutParams();
        layoutParams.height=LinearLayout.LayoutParams.WRAP_CONTENT;
        gridView.setLayoutParams( layoutParams );
        //设置tab滚动模式
        Tab.setTabMode( TabLayout.MODE_FIXED );
        MainActivity.info="sh";
        Tools.SetBarTitle( tb,barTitle,"生活缴费",search, LivePaymentAt.this,false );
        Tools.SetBanner("/prod-api/api/living/rotation/list", "","rows","advImg",rbt,this);
        Tools.SetCard( "/prod-api/api/living/category/list","","url","data","id" ,"imgUrl","liveName",LivePaymentAt.this,cardBeans,gridView);
        Tools.GetXwFl( "/prod-api/api/living/press/category/list", "",LivePaymentAt.this,"data",tabTitle,tabId,fragments,XwPager,Tab,getSupportFragmentManager() );

        gridView.setOnItemClickListener( (parent, view, position, id) -> {
                switch (view.getTag().toString()){
                    case "手机话费":
                    case "水费":
                    case "电费":
                    case "燃气费":
                        break;
                }
        } );
    }
}